<?
define('APPDIR', __DIR__ . '/');
define('LIBDIR', APPDIR . '../lib/');
// use core
require_once LIBDIR . 'core.php';

// include config...
AppCore::using('config');

// use xml
AppCore::using('Util_Xml');

// use Dao_Commentor
$dao = AppCore::getDao('Dao_Commentor');
if ($dao instanceof Dao_Commentor) {
    $sites = $dao->getTokens();
    AppCore::using('XmlRpc_Server');
    $s = new XmlRpc_Server($sites);
    // register a delegate
    $s->register($dao, array('getCommentsByArticleId', 'saveComment'));

    // start listening...
    $s->listen();
}

// add a new one in...
/*
$cmt = new Model_Commentor_Comment();
$cmt->setActive(1)
    ->setTitle('123 - a new one')
    ->setArticleId(231)
    ->setComment('More comments to follow!!!')
    ->setSiteId(31)
    ->setUserId(4)
    ->setCreatedBy(Util_Date::getGmdate());
//*/
// AppCore::dump($cmt, $cmt->getCreatedBy(+1000));
// $dao->saveComment($cmt);

// insert some damn sites...
// $dao->addSite('oddsligaen', 'http://oddsligaen.com.au');

// test listener...
?>